/*
 * @Author: 杨超
 * @Date: 2021-09-29 09:48:17
 * @LastEditTime: 2021-12-29 17:37:42
 * @LastEditors: 杨超
 * @Description: 适用于后端不给转换问题；通过不同的位置类型locationType，处理返回对应的位置值
 */

/**
 * 
 * @param {object} item 
 * @returns 位置，可能是设备名，也可能是桩号
 */
const useLocation = (item) => {
    // locationType: 1 => 设施; 2 => 桩号; 3 => 桩号范围
    let location = ''
    switch (item.locationType) {
        case 1:
            location = item.facilityName
            break
        case 2:
            location = item.stakeMiddle
            break
        case 3:
            location = item.stakeStart + '~' + item.stakeEnd
            break
        default:
            location = '-'
            break
    }
    return location
}

// 后端乱七八糟的另一个拼接
const useLocation2 = (item) => {
    // locationType: 1 => 设施; 2 => 桩号; 3 => 桩号范围
    let location = ''
    switch (item.locationType) {
        case 1:
            location = item.facilitiesName
            break
        case 2:
            location = item.stake
            break
        case 3:
            location = `K${item.startStake1}+${item.startStake2}~K${item.endStake1}+${item.endStake2}`
            break
        default:
            location = ''
            break
    }
    return location
}

export default useLocation
export {
    useLocation,
    useLocation2
}

